package com.weng.cloud.service8881.sleuth;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Author: weng
 * @Date: 2022/3/12
 * @Description: com.weng.cloud.service8883.sleuth
 */
@RestController
public class SleuthController {

//    @Bean
//    @LoadBalanced
//    public RestTemplate restTemplate(){
//        return new RestTemplate();
//    }

    @Value("${spring.application.name}")
    private String to;
    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/testSleuth")
    public String testSleuth(){
        System.err.println("FEEL OUT OF PLACE AND OUT OF TIME !!!");
        String url = "http://weng-cloud-service-8882/testSleuth/"+to;
        return this.restTemplate.getForObject(url,String.class);
    }
}
